package com.gz.moreaseManager.sys.controller;

import com.gz.moreaseManager.core.ueditor.ActionEnter;
import com.gz.moreaseManager.core.ueditor.upload.StorageManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.ClassUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @文件名: ServerController
 * @版权:Copyright 2018-2020版权所有：ganz
 * @描述: 配置ueditor的控制层
 * @修改人: ganzheng
 * @修改时间: 9:34
 * @修改内容:新增
 */
@RestController
public class ServerController {
    private static final Logger logger = LoggerFactory.getLogger(StorageManager.class);

    @RequestMapping(value = "/config")
    public void config(HttpServletRequest request, HttpServletResponse response){
        response.setContentType("application/json");
        String rootPath = request.getSession().getServletContext().getRealPath("/");
        logger.info("rootPath ==="+ rootPath ) ;
        try{

            response.setCharacterEncoding("UTF-8");
            String exec = new ActionEnter(request,rootPath).exec();
            PrintWriter writer = response.getWriter();
            writer.write(exec);
            writer.flush();
            writer.close();
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
